/**
 * @file TcpServer.h
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2022-04-05
 *
 * @copyright Copyright (c) 2022
 *
 */

#pragma once

#include "EpollEvent.h"
#include "TcpConnection.h"

namespace wd
{

class TcpServer
{
  public:
    typedef TcpConnection::TcpConnectionCallback TcpServerCallback;

    TcpServer(unsigned short port);
    TcpServer(const char *pIp, unsigned short port);

    void start();
    void stop();

    void setConnectionCallback(TcpServerCallback cb);
    void setMessageCallback(TcpServerCallback cb);
    void setCloseCallback(TcpServerCallback cb);

  private:
    InetAddress inetAddr_;
    Socket sockfd_;
    EpollEvent epollfd_;

    TcpServerCallback onConnectionCb_;
    TcpServerCallback onMessageCb_;
    TcpServerCallback onCloseCb_;
};

} // end of namespace wd
